home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Misc Servers / Zope.exe / DTML-STRING.STX < prev    next >
Encoding:
Text File  |  2000-10-31  |  6.7 KB  |  151 lines

  1. string: DTML String Functions
  2.  
  3.   The 'string' modules provides string manipulation, conversion, and
  4.   searching functions. It is a standard Python module.
  5.  
  6.   Functions
  7.  
  8.     atof(s) -- Convert a string to a floating point number. The string
  9.       must have the standard syntax for a floating point literal in Python,
  10.       optionally preceded by a sign ("+" or "-"). Note that this behaves
  11.       identical to the built-in function float() when passed a string.
  12.  
  13.     atoi(s [,base]) -- Convert string s to an integer in the given
  14.       base. The string must consist of one or more digits, optionally
  15.       preceded by a sign ("+" or "-"). The base defaults to 10. If it is 0,
  16.       a default base is chosen depending on the leading characters of the
  17.       string (after stripping the sign): "0x" or "0X" means 16, "0" means
  18.       8, anything else means 10. If base is 16, a leading "0x" or "0X" is
  19.       always accepted, though not required.
  20.  
  21.     atol(s, [,base]) --Convert string s to a long integer in the given
  22.       base. The string must consist of one or more digits, optionally
  23.       preceded by a sign ("+" or "-"). The base argument has the same
  24.       meaning as for atoi(). A trailing "l" or "L" is not allowed,
  25.       except if the base is 0. Note that when invoked without base or
  26.       with base set to 10,
  27.  
  28.     capitalize(word) -- Capitalize the first character of the argument. 
  29.  
  30.     capwords(s) -- Split the argument into words using split(),
  31.       capitalize each word using capitalize(), and join the capitalized
  32.       words using join(). Note that this replaces runs of whitespace
  33.       characters by a single space, and removes leading and trailing
  34.       whitespace.
  35.  
  36.     find(s, sub [,start [,end]]) -- Return the lowest index in s where
  37.       the substring sub is found such that sub is wholly contained in
  38.       s[start:end]. Return -1 on failure. Defaults for start and end and
  39.       interpretation of negative values is the same as for slices.
  40.  
  41.     rfind(s, sub [,start [,end]]) -- Like find() but find the highest
  42.       index.
  43.  
  44.     index(s, sub [,start [,end]]) -- Like find() but raise ValueError
  45.       when the substring is not found.
  46.  
  47.     rindex(s, sub [,start [,end]]) -- Like rfind() but raise ValueError
  48.       when the substring is not found.
  49.  
  50.     count(s, sub [,start [,end]]) -- Return the number of
  51.       (non-overlapping) occurrences of substring sub in string
  52.       s[start:end]. Defaults for start and end and interpretation of
  53.       negative values are the same as for slices.
  54.  
  55.     lower(s) -- Return a copy of s, but with upper case letters
  56.       converted to lower case.
  57.  
  58.     makestrans(from, to) -- Return a translation table suitable for passing
  59.       to translate() that will map each character in from into the
  60.       character at the same position in to; from and to must have the
  61.       same length.
  62.  
  63.     split(s, [,sep [,maxsplit]]) -- Return a list of the words of the
  64.       string s. If the optional second argument sep is absent or None, the
  65.       words are separated by arbitrary strings of whitespace characters
  66.       (space, tab, newline, return, formfeed). If the second argument sep
  67.       is present and not None, it specifies a string to be used as the word
  68.       separator. The returned list will then have one more item than the
  69.       number of non-overlapping occurrences of the separator in the
  70.       string. The optional third argument maxsplit defaults to 0. If it is
  71.       nonzero, at most maxsplit number of splits occur, and the remainder
  72.       of the string is returned as the final element of the list (thus, the
  73.       list will have at most maxsplit+1 elements).
  74.  
  75.     join(words [,sep]) -- Concatenate a list or tuple of words
  76.       with intervening occurrences of sep. The default value for sep
  77.       is a single space character. It is always true that
  78.       'string.join(string.split(s, sep), sep)' equals s.
  79.  
  80.     lstrip(string) -- Return a copy of s but without leading whitespace
  81.       characters.
  82.  
  83.     rstrip(string) -- Return a copy of s but without trailing whitespace
  84.       characters.
  85.  
  86.     strip(string) -- Return a copy of s without leading or trailing
  87.       whitespace.
  88.  
  89.     swapcase(s) -- Return a copy of s, but with lower case letters
  90.       converted to upper case and vice versa.
  91.  
  92.     translate(s, table [,deletechars]) -- Delete all characters from s
  93.       that are in deletechars (if present), and then translate the
  94.       characters using table, which must be a 256-character string giving
  95.       the translation for each character value, indexed by its ordinal.
  96.  
  97.     upper(s) -- Return a copy of string, but with lower case letters
  98.       converted to upper case.
  99.  
  100.     ljust(string, width) -- Left-justifies a string in a field of
  101.       given width. Returns a string that is at least width characters
  102.       wide, created by padding the string with spaces until the given
  103.       width. The string is never truncated.
  104.  
  105.     rjust(string, width) -- Right-justifies a string in a field of
  106.       given width.  Returns a string that is at least width characters
  107.       wide, created by padding the string s with spaces until the
  108.       given width. The string is never truncated.
  109.  
  110.  
  111.     center(string, width) -- Centers a string in a field of given
  112.       width. Returns a string that is at least width characters wide,
  113.       created by padding the string s with spaces until the given
  114.       width. The string is never truncated.
  115.  
  116.     zfill(s, width) -- Pad a numeric string on the left with zero
  117.       digits until the given width is reached. Strings starting with a sign
  118.       are handled correctly.
  119.  
  120.     replace(s, old, new [,maxsplit]) -- Return a copy of string s with
  121.       all occurrences of substring old replaced by new. If the optional
  122.       argument maxsplit is given, the first maxsplit occurrences are
  123.       replaced.
  124.  
  125.   Attributes
  126.  
  127.     digits -- The string '0123456789'
  128.  
  129.     hexdigits -- The string '0123456789abcdefABCDEF'.
  130.  
  131.     letters -- The concatenation of the strings 'lowercase' and 'uppercase' described below.
  132.  
  133.     lowercase -- A string containing all the characters that are considered
  134.       lowercase letters. On most systems this is the string
  135.       'abcdefghijklmnopqrstuvwxyz'. 
  136.  
  137.     octdigits -- The string '01234567'. 
  138.  
  139.     uppercase -- A string containing all the characters that are considered
  140.       uppercase letters. On most systems this is the string
  141.       'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
  142.  
  143.     whitespace -- A string containing all characters that are considered
  144.       whitespace. On most systems this includes the characters space, tab,
  145.       linefeed, return, formfeed, and vertical tab.
  146.   
  147.   See Also
  148.  
  149.     "Python 'string' module":http://www.python.org/doc/current/lib/module-string.html
  150.  
  151.